package opc.read.kafka;

import opc.read.config.PathConf;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;

import java.util.Properties;

public class KafkaSelfProducer {

    public static Producer getProducer() {
        Properties props = new Properties();
        //192.168.10.194:9092,192.168.10.221:9092,192.168.10.193:9092
        //10.129.110.11:9092,10.129.110.12:9092,10.129.110.18:9092
        //192.168.10.199    192.168.10.212
        props.put("bootstrap.servers", PathConf.kafkaServer);
        props.put("acks", "all");
        props.put("retries", 0);
        props.put("batch.size", 16384); // 16KB
        props.put("linger.ms", 1);
        props.put("buffer.memory", 33554432); // 32MB
        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");

        Producer<String, String> producer = new KafkaProducer<String, String>(props);
        System.out.println("i am kafka:"+producer.toString());
        return producer;
    }
}
